<?php
class menu_6h
{

    public $tbl = NULL;
    public $menuArr = array
        (
        0 => array
            (
            0 => "特码",
            1 => "onlinebet",
            2 => "now1",
            3 => "unow1",
            4 => "snow1",
            5 => "bnow1",
            6 => array
                (
                0 => array
                    (
                    0 => "1001,1,2,3,13,14,18,20,28,30,47,49,50",
                    1 => "0,1,2,3,13,14,18,20,28,30,47,49,50",
                    2 => "1,2,3,13,14,18,20,28,30,47,49,50"
                ),
                1 => "1001,1,2,3,13,14,18,20,28,30,47,49,50",
                2 => "1001,1,2,3,20,28,30,47,49,50",
                3 => "1001,1,2,3,13,14,18,20,28,30,47,49,50",
                4 => "1001,1,2,3,20,28,30,47,49,50"
            )
        ),
				   9991 => array
            (
            0 => "特整合",
            1 => "bnow31",
            2 => "now9",
            3 => "unow5",
            4 => "",
            5 => "bnow6",
            6 => array
                (
                0 => "",
                1 => "",
                2 => "",
                3 => "",
                4 => ""
            )
        ),
        13 => array
            (
            0 => "生肖色波",
            1 => "",
            2 => "",
            3 => "unow12",
            4 => "",
            5 => "bnow12",
            6 => array
                (
                0 => "",
                1 => "",
                2 => "13,14,18",
                3 => "",
                4 => "13,14,18"
            )
        ),
        18 => array
            (
            0 => "半波",
            1 => "",
            2 => "",
            3 => "",
            4 => "",
            5 => "",
            6 => array
                (
                0 => "",
                1 => "",
                2 => "",
                3 => "",
                4 => ""
            )
        ),
        19 => array
            (
            0 => "合肖",
            1 => "onlinebet0",
            2 => "now1_1",
            3 => "unow4",
            4 => "snow1_1",
            5 => "bnow4",
            6 => array
                (
                0 => "19",
                1 => "19",
                2 => "19",
                3 => "19",
                4 => "19"
            )
        ),
        4 => array
            (
            0 => "正码",
            1 => "onlinebet2",
            2 => "now2",
            3 => "unow2",
            4 => "snow2",
            5 => "bnow2",
            6 => array
                (
                0 => array
                    (
                    0 => "1002,5,6,15,16,17,23",
                    1 => "4,5,6,15,16,17,23",
                    2 => "5,6,15,16,17,23,31"
                ),
                1 => "1002,5,6,15,16,17,23",
                2 => "1002,5,6",
                3 => "1002,5,6,15,16,17,23",
                4 => "1002,5,6"
            )
        ),
        15 => array
            (
            0 => "正1~6",
            1 => "",
            2 => "",
            3 => "unow22",
            4 => "",
            5 => "bnow22",
            6 => array
                (
                0 => "",
                1 => "",
                2 => "15,16,17,23",
                3 => "",
                4 => "15,16,17,23"
            )
        ),
        25 => array
            (
            0 => "正码特",
            1 => "onlinebet4",
            2 => "now4",
            3 => "unow23",
            4 => "snow4",
            5 => "bnow23",
            6 => array
                (
                0 => array
                    (
                    0 => "1003",
                    1 => "25",
                    2 => "26"
                ),
                1 => "1003",
                2 => "1003",
                3 => "1003",
                4 => "1003"
            )
        ),
        21 => array
            (
            0 => "一肖尾数",
            1 => "onlinebet3",
            2 => "now3",
            3 => "unow7",
            4 => "snow3",
            5 => "bnow5",
            6 => array
                (
                0 => array
                    (
                    0 => "1006,1007,34,35",
                    1 => "21,22,34,35",
                    2 => "37,38,34,35"
                ),
                1 => "1006,1007,34,35",
                2 => "1006,1007,34,35",
                3 => "1006, 1007,34,35",
                4 => "1006,1007,34,35"
            )
        ),
        8 => array
            (
            0 => "连码",
            1 => "onlinebet5",
            2 => "now5",
            3 => "unow3",
            4 => "",
            5 => "bnow3",
            6 => array
                (
                0 => "7,8,9,10,11,48",
                1 => "7,8,9,10,11,48",
                2 => "7,8,9,10,11,48",
                3 => "",
                4 => "7,8,9,10,11,48"
            )
        ),
        29 => array
            (
            0 => "自选不中",
            1 => "onlinebet8",
            2 => "now8",
            3 => "unow29",
            4 => "",
            5 => "bnow29",
            6 => array
                (
                0 => "29,39,40,41,42,43,44,45",
                1 => "29,39,40,41,42,43,44,45",
                2 => "29,39,40,41,42,43,44,45",
                3 => "",
                4 => "29,39,40,41,42,43,44,45"
            )
        ),
        27 => array
            (
            0 => "连肖",
            1 => "onlinebet6",
            2 => "now6",
            3 => "unow8",
            4 => "",
            5 => "bnow7",
            6 => array
                (
                0 => "27",
                1 => "27",
                2 => "27",
                3 => "",
                4 => "27"
            )
        ),
        36 => array
            (
            0 => "连尾",
            1 => "onlinebet7",
            2 => "now7",
            3 => "unow36",
            4 => "",
            5 => "bnow36",
            6 => array
                (
                0 => "36",
                1 => "36",
                2 => "36",
                3 => "",
                4 => "36"
            )
        ),
        12 => array
            (
            0 => "过关",
            1 => "",
            2 => "",
            3 => "unow9",
            4 => "",
            5 => "",
            6 => array
                (
                0 => "",
                1 => "",
                2 => "12",
                3 => "",
                4 => ""
            )
        ),
     
        9992 => array
            (
            0 => "列表",
            1 => "",
            2 => "",
            3 => "unow6",
            4 => "",
            5 => "",
            6 => array
                (
                0 => "",
                1 => "",
                2 => "",
                3 => "",
                4 => ""
            )
        ),
        9993 => array
            (
            0 => "全部",
            1 => "onlinebet1",
            2 => "",
            3 => "",
            4 => "",
            5 => "",
            6 => array
                (
                0 => "",
                1 => "",
                2 => "",
                3 => "",
                4 => ""
            )
        )
    );
    public $mode = NULL;
    public $lotto_id = NULL;
    public $split_id = NULL;
    public $disk_id = NULL;
    public $bypercent = NULL;
    public $disks = NULL;
    public $open = NULL;
    public $round = NULL;
    public $betmode = NULL;
    public $norder = NULL;
    public $_6hmenu_enabled = NULL;
    public $diskStr = NULL;
    public $pnStr = NULL;
    public $sumbetArr = array
        (
        0 => "onlinebet5",
        1 => "onlinebet8",
        2 => "onlinebet6",
        3 => "onlinebet7",
        4 => "now5",
        5 => "now8",
        6 => "now6",
        7 => "now7",
        8 => "unow3",
        9 => "unow29",
        10 => "unow8",
        11 => "unow36",
        12 => "unow9",
        13 => "bnow3",
        14 => "bnow29",
        15 => "bnow7",
        16 => "bnow36"
    );

    public function menu_6h ($mode = 0, $fieldArr = array())
    {
        global $g_6hmenu_enabled;
        global $g_disk_code;
        $this->_6hmenu_enabled = $g_6hmenu_enabled;
        $this->mode = $mode;
        $this->lotto_id = isset($fieldArr['lotto_id']) ? $fieldArr['lotto_id'] : 0;
        $this->split_id = isset($fieldArr['split_id']) ? $fieldArr['split_id'] : 0;
        $this->disk_id = isset($fieldArr['disk_id']) ? $fieldArr['disk_id'] : 0;
        $this->diskStr = isset($g_disk_code[$this->disk_id]) ? $g_disk_code[$this->disk_id] : "";
        $this->bypercent = isset($fieldArr['bypercent']) ? $fieldArr['bypercent'] : "";
        $this->disks = isset($fieldArr['disks']) ? $fieldArr['disks'] : "";
        $this->betmode = isset($fieldArr['betmode']) ? $fieldArr['betmode'] : "";
        $this->open = isset($fieldArr['open']) ? $fieldArr['open'] : "0000-00-00";
        $this->round = isset($fieldArr['round']) ? $fieldArr['round'] : "";
        $this->norder = isset($fieldArr['norder']) ? $fieldArr['norder'] : 1;
        $this->pnStr = isset($fieldArr['pnStr']) ? $fieldArr['pnStr'] : "";
        $this->bets = isset($fieldArr['bets']) ? $fieldArr['bets'] : 0;
    }

    public function getMenu ($select = 0)
    {
        $menuList = "";
		
        switch ($this->mode)
        {
            case 0 :
                $menuList = "<table class='tblMy3D' bgcolor='#CFCFFF' width='980'>";
                $menuList .= "<tr class='bgImg_0'><td colspan='10'><span style=\"float: left\">{$this->pnStr}</span><span style=\"float: right\">{$this->menuArr[$select][0]}&nbsp;" . L_REALTIME . "&nbsp;&nbsp;{$this->bypercent}&nbsp;{$this->disks}&nbsp;{$this->betmode}</span></td></tr>";
                $menuList .= "<tr class='td6' style='text-align:center'>";
                $totalAmo = 0;
                $bgClcStr = "";
                foreach ($this->menuArr as $i => $val)
                {
				
				
					if (empty($this->menuArr[$i][1]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
					
                    if (is_array($this->menuArr[$i][6][0]))
                    {
                        if (isset($this->menuArr[$i][6][0][$this->bets]))
                        {
                            $getDataBettype = $this->menuArr[$i][6][0][$this->bets];
                        }
                        else
                        {
                            $getDataBettype = $this->menuArr[$i][6][0][0];
                        }
                    }
                    else
                    {
                        $getDataBettype = $this->menuArr[$i][6][0];
                    }
					 
                    if (in_array($this->menuArr[$i][1], $this->sumbetArr))
                    {
                        $betDataArr = $this->getBetTotal($getDataBettype);
						
						
                    }
                    else
                    {
                        $betDataArr = $this->getDataListTotal($getDataBettype);
						
						
                    }
                    $totalAmo += $betDataArr[0];
                    if ($betDataArr[1])
                    {
                        $bgClcStr = $betDataArr[1];
                    }
                    if ($i == 9993)
                    {
						$gg =$this->getBetTotal(12);
                        $betDataArr[0] = $totalAmo+$gg[0];
                        $betDataArr[1] = $bgClcStr;
                    }
					
                    if ($i == $select)
                    {
                        $menuList .= "<td class='td2'>" . $this->menuArr[$select][0] . "(<span style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</td>";
                    }
                    else
                    {
                        $menuList .= "<td><a href=\"op.php?op=agent&fp=" . $this->menuArr[$i][1] . "&lotto_id={$this->lotto_id}&split={$this->split_id}&disk={$this->disk_id}&select={$i}\">" . $this->menuArr[$i][0] . "(<span style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</a></td>";
                    }
                }
                $menuList .= "</tr></table>";
				
                break;
            case 1 :
            case 3 :
                $menuList = "<table class='tblMy3D' bgcolor='#CFCFFF' width='990'><tr class='td6' style='text-align:center'>";
                $j = 0;
                if ($this->mode == 1)
                {
                    $menuList .= "<td width='200' class='bgImg_0'>" . $this->menuArr[$select][0] . " 操盘室&#12288;{$this->round}期 {$this->open}</td>";
                }
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][2]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    if (9990 < $i)
                    {
                        $betDataArr = array();
                        $betDataArr[0] = "--";
                        $betDataArr[1] = "";
                    }
                    else
                    {
                        $getDataBettype = $this->menuArr[$i][6][1];
                        if (in_array($this->menuArr[$i][2], $this->sumbetArr))
                        {
                            $betDataArr = $this->getBetTotal($getDataBettype);
                        }
                        else
                        {
                            $betDataArr = $this->getDataListTotal($getDataBettype);
                        }
                    }
                    if ($this->mode == 3)
                    {
                        $menuList .= "<td><a href=\"javascript:clickTitle('{$this->menuArr[$i][2]}', '{$i}');\">" . $this->menuArr[$i][0] . "(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</a></td>";
                    }
                    else if ($i == $select)
                    {
                        $menuList .= "<td class='td2'>" . $this->menuArr[$select][0] . "(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</td>";
                    }
                    else
                    {
                        $menuList .= "<td><a href=\"op.php?op=admin&fp=" . $this->menuArr[$i][2] . "&norder={$this->norder}&select={$i}\">" . $this->menuArr[$i][0] . "(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</a></td>";
                    }
                    ++$j;
                }
                $menuList .= "<td><input type=\"button\" value=\"纪录\" onclick=\"javascript:showRateRecordPage(0, '{$this->open}') \"/></td>";
                $menuList .= "</tr></table>";
                break;
            case 2 :
                $menuList = "<table class='tblMy3D' width='980'><tr class='td6' style='text-align:center'>";
                $menuList .= "<td width='200' class='bgClc_0'>{$this->menuArr[$select][0]} 走飞&#12288;{$this->round}期 {$this->open}</td>";
                $j = 0;
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][3]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    if (9990 < $i)
                    {
                        $betDataArr = array();
                        $betDataArr[0] = "--";
                        $betDataArr[1] = "";
                    }
                    else
                    {
                        $getDataBettype = $this->menuArr[$i][6][2];
                        if (in_array($this->menuArr[$i][3], $this->sumbetArr))
                        {
                            $betDataArr = $this->getBetTotal($getDataBettype);
                        }
                        else
                        {
                            $betDataArr = $this->getDataListTotal($getDataBettype);
                        }
                    }
                    if ($i == $select)
                    {
                        $menuList .= "<td class='td2' nowrap>" . $this->menuArr[$select][0] . "<br />(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</td>";
                    }
                    else
                    {
                        $menuList .= "<td  nowrap><a href=\"op.php?op=admin&fp=" . $this->menuArr[$i][3] . "&norder={$this->norder}&select={$i}\">" . $this->menuArr[$i][0] . "</a><br />(<span id='menuAmu{$j}' style='color:#cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</td>";
                    }
                    ++$j;
                }
                $menuList .= "</tr></table>";
                break;
            case 11 :
                $menuList = "<table class='tblMy3D' width='980'><tr class='td6' style='text-align:center'>";
                $menuList .= "<td width='200' class='bgImg_0'>" . $this->menuArr[$select][0] . " 操盘室&#12288;{$this->round}期 {$this->open}</td>";
                $j = 0;
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][4]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    $getDataBettype = $this->menuArr[$i][6][3];
                    if (in_array($this->menuArr[$i][4], $this->sumbetArr))
                    {
                        $betDataArr = $this->getBetTotal($getDataBettype);
                    }
                    else
                    {
                        $betDataArr = $this->getDataListTotal($getDataBettype);
                    }
                    if ($i == $select)
                    {
                        $menuList .= "<td class='td2'>" . $this->menuArr[$select][0] . "(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</td>";
                    }
                    else
                    {
                        $menuList .= "<td><a href=\"op.php?op=subsidary&fp=" . $this->menuArr[$i][4] . "&norder={$this->norder}&select={$i}\">" . $this->menuArr[$i][0] . "(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</a></td>";
                    }
                    ++$j;
                }
                $menuList .= "</tr>";
                $menuList .= "</table>";
                break;
            case 12 :
                $menuList = "<table class='tblMy3D' width='980'><tr class='td6' style='text-align:center'>";
                $menuList .= "<td width='140' class='bgClc_0'>" . $this->menuArr[$select][0] . " 走飞操盘室<br />日期:{$this->open}</td>";
                $j = 0;
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][5]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    if (9990 < $i)
                    {
                        $betDataArr = array();
                        $betDataArr[0] = "--";
                        $betDataArr[1] = "";
                    }
                    else
                    {
                        $getDataBettype = $this->menuArr[$i][6][4];
                        if (in_array($this->menuArr[$i][5], $this->sumbetArr))
                        {
                            $betDataArr = $this->getBetTotal($getDataBettype);
                        }
                        else
                        {
                            $betDataArr = $this->getDataListTotal($getDataBettype);
                        }
                    }
                    if ($i == $select)
                    {
                        $menuList .= "<td class='td2'>" . $this->menuArr[$select][0] . "<br />(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</td>";
                    }
                    else
                    {
                        $menuList .= "<td><a href=\"op.php?op=agent&fp=" . $this->menuArr[$i][5] . "&norder={$this->norder}&select={$i}\">" . $this->menuArr[$i][0] . "<br />(<span id='menuAmu{$j}' style='color: #cc0000;{$betDataArr[1]}'>{$betDataArr[0]}</span>)</a></td>";
                    }
                    ++$j;
                }
                $menuList .= "</tr></table>";
                break;
            case 31 :
                $menuList = "";
                $menuList .= $this->_6hmenu_enabled[0] ? posToMenu("特码", "?op=member&fp=bet0", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[13] ? posToMenu("生肖色波", "?op=member&fp=bet6", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[18] ? posToMenu("半波", "?op=member&fp=bet7", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[19] ? posToMenu("合肖", "?op=member&fp=bet8", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[4] ? posToMenu("正码", "?op=member&fp=bet2a", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[15] ? posToMenu("正码1~6", "?op=member&fp=bet3", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[8] ? posToMenu("连码", "?op=member&fp=bet5", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[29] ? posToMenu("自选不中", "?op=member&fp=bet29", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[12] ? posToMenu("过关", "?op=member&fp=bet4", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[21] ? posToMenu("一肖尾数", "?op=member&fp=bet9", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[27] ? posToMenu("连肖", "?op=member&fp=bet10", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[36] ? posToMenu("连尾", "?op=member&fp=bet36", "mainFrame", "r1") : "";
                $menuList .= $this->_6hmenu_enabled[25] ? posToMenu("正码特", "?op=member&fp=bet2t", "mainFrame", "r1") : "";
                break;
        }
        return $menuList;
    }

    public function getMenuAmu ()
    {
        $menuList = "";
        switch ($this->mode)
        {
            case 1 :
                $menuList = "";
                $menuListArr = array();
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][2]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    if (9990 < $i)
                    {
                        $betDataArr = array();
                        $betDataArr[0] = "--";
                        $betDataArr[1] = "";
                    }
                    else
                    {
                        $getDataBettype = $this->menuArr[$i][6][1];
                        if (in_array($this->menuArr[$i][2], $this->sumbetArr))
                        {
                            $betDataArr = $this->getBetTotal($getDataBettype);
                        }
                        else
                        {
                            $betDataArr = $this->getDataListTotal($getDataBettype);
                        }
                    }
                    $menuListArr[] = $betDataArr[0] . "@" . ( $betDataArr[1] != "" ? "1" : "0" );
                }
                $menuList = implode(",", $menuListArr);
                break;
            case 2 :
                $menuList = "";
                $menuListArr = array();
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][3]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    if (9990 < $i)
                    {
                        $betDataArr = array();
                        $betDataArr[0] = "--";
                        $betDataArr[1] = "";
                    }
                    else
                    {
                        $getDataBettype = $this->menuArr[$i][6][2];
                        if (in_array($this->menuArr[$i][3], $this->sumbetArr))
                        {
                            $betDataArr = $this->getBetTotal($getDataBettype);
                        }
                        else
                        {
                            $betDataArr = $this->getDataListTotal($getDataBettype);
                        }
                    }
                    $menuListArr[] = $betDataArr[0] . "@" . ( $betDataArr[1] != "" ? "1" : "0" );
                }
                $menuList = implode(",", $menuListArr);
                break;
            case 11 :
                $menuList = "";
                $menuListArr = array();
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][4]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    $getDataBettype = $this->menuArr[$i][6][3];
                    if (in_array($this->menuArr[$i][4], $this->sumbetArr))
                    {
                        $betDataArr = $this->getBetTotal($getDataBettype);
                    }
                    else
                    {
                        $betDataArr = $this->getDataListTotal($getDataBettype);
                    }
                    $menuListArr[] = $betDataArr[0] . "@" . ( $betDataArr[1] != "" ? "1" : "0" );
                }
                $menuList = implode(",", $menuListArr);
                break;
            case 12 :
                $menuList = "";
                $menuListArr = array();
                foreach ($this->menuArr as $i => $val)
                {
                    if (empty($this->menuArr[$i][5]))
                    {
                        continue;
                    }
                    if ($this->_6hmenu_enabled[$i] == 0)
                    {
                        continue;
                    }
                    if (9990 < $i)
                    {
                        $betDataArr = array();
                        $betDataArr[0] = "--";
                        $betDataArr[1] = "";
                    }
                    else
                    {
                        $getDataBettype = $this->menuArr[$i][6][4];
                        if (in_array($this->menuArr[$i][5], $this->sumbetArr))
                        {
                            $betDataArr = $this->getBetTotal($getDataBettype);
                        }
                        $betDataArr = $this->getDataListTotal($getDataBettype);
                    }
                    $menuListArr[] = $betDataArr[0] . "@" . ( $betDataArr[1] != "" ? "1" : "0" );
                }
                $menuList = implode(",", $menuListArr);
                break;
        }
        return $menuList;
    }

    public function getDataListTotal ($bettypeStr)
    {
        global $curruser;
        if ($bettypeStr === "")
        {
            return array(0, "");
        }
        if ($curruser['acl'] < 255)
        {
            $showid = $curruser['id'];
        }
        else
        {
            $showid = 0;
        }
        $reArr = array();
        if ($this->split_id == 0)
        {
            $amountstr = "amount1{$this->diskStr}";
        }
        else
        {
            $amountstr = "amount2{$this->diskStr}";
        }
        $sql = "SELECT sum({$amountstr}) as amount, max(updatetime) as uptime FROM bettotal_6h_{$this->lotto_id}";
        $sql .= " WHERE user_id={$showid} AND bettype IN ({$bettypeStr}) AND lotto_id={$this->lotto_id}";
        $rs = getdb($sql);
        if ($rs->eof)
        {
            return array(0, "");
        }
        return array(intval($rs->f[0]), systime() - intval($rs->f[1]) < 40 ? "background-color:#ffff99;" : "");
    }

    public function getBetTotal ($bettypeStr)
    {
        global $curruser;
        $noDataArr = array(0, "");
        if ($bettypeStr === "")
        {
            return $noDataArr;
        }
        $userid = $curruser['id'];
        $theacl = $curruser['acl'];
        $bet_usersql = "";
        $bet2_usersql = "";
        $bet8_usersql = "";
        if ($curruser['acl'] != 255)
        {
            $userlist = GetUserList($curruser['id']);
            if ($userlist == "")
            {
                return $noDataArr;
            }
            $bet_usersql = " and user_id in ({$userlist})";
            $bet2_usersql = " and uperid{$theacl}={$userid}";
            $bet8_usersql = " and user_id={$userid}";
            if ($curruser['acl'] == 2)
            {
                $bet2_usersql = " and user_id=0 ";
            }
        }
        if (0 < $this->disk_id)
        {
            $disksql = " and disk=" . $this->disk_id;
        }
        else
        {
            $disksql = "";
        }
        $bet_percent = "";
        $bet2_percent = "";
        $bet28 = "bet2";
		
        if ($this->split_id == 1)
        {
            switch ($theacl)
            {
                case 2 :
                    $bet_percent = "*mpercent/100";
                    $bet2_percent = "";
                    break;
                case 3 :
                    $bet_percent = "*percent2/100";
                    $bet2_percent = "*percent3/100";
                    break;
                case 4 :
                    $bet_percent = "*percent3/100";
                    $bet2_percent = "*percent4/100-amount";
                    break;
                case 5 :
                    $bet_percent = "*percent4/100";
                    $bet2_percent = "*percent5/100";
                    break;
                default :
                    $bet_percent = "*upercent/100";
                    $bet2_percent = "*percent255/100";
                    break;
            }
            $bet28 = "bet8";
        }

        $betTypeStr = "bettype IN ( " . $bettypeStr . ")";
        $sql = " sum(totalAmt) as totalAmt, max(crtTime) as crtTime FROM ( ";
        $sql .= " (Select sum(amount{$bet_percent}) as totalAmt, max(createtime) as crtTime ";
        $sql .= " from bet where {$betTypeStr} and lotto_id={$this->lotto_id} {$bet_usersql} and rame in (0,9) {$disksql}  GROUP BY lotto_id )";
        $sql .= " UNION ALL ";
        $sql .= " (Select sum(amount{$bet2_percent}) as totalAmt, max(createtime) as crtTime ";
        $sql .= " from bet2 where {$betTypeStr} and lotto_id={$this->lotto_id} {$bet2_usersql} and rame in (0,9) GROUP BY lotto_id)";
        $sql .= " UNION ALL ";
        $sql .= " (Select sum(amount*-1) as totalAmt , max(createtime) as crtTime";
        $sql .= " from {$bet28} where {$betTypeStr} and lotto_id={$this->lotto_id} {$bet8_usersql} and rame in (0,9) GROUP BY lotto_id)";
        $sql .= " ) A";
        $rs = getdb("SELECT " . $sql);
		
        if ($rs->eof)
        {
            return array(0, "");
        }
        return array(intval($rs->f[0]), systime() - intval($rs->f[1]) < 40 ? "background-color:#ffff99;" : "");
    }

}

?>